<?php
/**
 * Created by PhpStorm.
 * User: 耳火
 * Date: 2018/7/16
 * Time: 16:21
 */

namespace App\Services;


use App\Facades\Infra\StoreLevelManager;

class StoreLevelService
{
    //处理创建栏目逻辑
    public function createStoreLevel($data)
    {
        //数据库操作
        StoreLevelManager::createStoreLevel($this->formatData($data));
    }


    /**
     * 获取栏目信息
     * @param $conditions
     * @return mixed
     */
    public function getStoreLevels($conditions)
    {
        return StoreLevelManager::getStoreLevels($this->formatConditions($conditions), true, ['parant'])->paginate(15);
    }

    /**
     * 更新栏目
     * @param array $data
     */
    public function updateStoreLevel($data)
    {
        $conditions['id'] = $data['id'];
        StoreLevelManager::updateStoreLevel($this->formatConditions($conditions), $data);
    }

    public function deleteStoreLevel($conditions)
    {
        StoreLevelManager::deleteStoreLevel($conditions);
    }


    private function formatConditions($conditions){
        $conditions['hotel_id'] = \Auth::user()->id;

        return $conditions;
    }


    private function formatData($data)
    {
        $data['hotel_id'] = \Auth::user()->id;
        return $data;
    }
}